package cn.chia.front.dao.impl;

import java.util.List;

import org.apache.struts2.ServletActionContext;
import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Component;

import cn.chia.front.dao.IShopcarDAO;
import cn.chia.pojo.TblShopcar;
import cn.chia.pojo.User;


@Component
public class ShopcarDAOImpl extends HibernateDaoSupport implements IShopcarDAO{

	@Autowired
	public ShopcarDAOImpl(HibernateTemplate hibernateTemplate){
		super.setHibernateTemplate(hibernateTemplate);
	}
	
	public void doCreate(TblShopcar vo) throws Exception {
		// TODO Auto-generated method stub
		this.getHibernateTemplate().save(vo);
	}

	public void doRemove(Integer id) throws Exception {
		// TODO Auto-generated method stub
		Session session = this.getSession();
		Object o = session.get(TblShopcar.class, id);
		session.delete(o);
	}

	public void doUpdate(TblShopcar vo) throws Exception {
		// TODO Auto-generated method stub
		this.getHibernateTemplate().update(vo);
	}

	public List<TblShopcar> findAll(User user) throws Exception {
		// TODO Auto-generated method stub
		Session session = this.getSession();
		List<TblShopcar> list = (List<TblShopcar>)session.createQuery("from TblShopcar as t where t.user.userid="+user.getUserid()).list();
		return list;
	}

	public List<TblShopcar> findAll(int pageNo, int pageSize, String keyword,
			String column) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	public TblShopcar findById(Integer id) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	public int getAllCount(String keyword, String column) throws Exception {
		// TODO Auto-generated method stub
		return 0;
	}

	public List<TblShopcar> findAll() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

}
